import { Vec3 } from '@/core/types';
import { BlockType } from '@/blocks/types';

export interface RedstoneComponent {
  position: Vec3;
  type: BlockType;
  powerLevel: number;
  isPowered: boolean;
  lastUpdate: number;
}

export interface RedstonePower {
  level: number; // 0-15
  source: Vec3;
  lastUpdate: number;
  direction?: Vec3; // 信号传播方向
}

export interface RedstoneConnection {
  from: Vec3;
  to: Vec3;
  powerLevel: number;
  isActive: boolean;
}

export enum RedstoneComponentType {
  WIRE = 'wire',
  TORCH = 'torch',
  BUTTON = 'button',
  LEVER = 'lever',
  PRESSURE_PLATE = 'pressure_plate',
  PISTON = 'piston',
  DOOR = 'door',
  REPEATER = 'repeater',
  COMPARATOR = 'comparator'
}

export interface RedstoneState {
  components: Map<string, RedstoneComponent>;
  powerSources: Map<string, RedstonePower>;
  connections: RedstoneConnection[];
  updateQueue: Vec3[];
}

export interface RedstoneUpdateEvent {
  position: Vec3;
  oldPowerLevel: number;
  newPowerLevel: number;
  timestamp: number;
}